package com.decade.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * redission 配置类
 * @author gzk
 * @date 2021/37/11 15:37
 */
@Configuration
public class RedissonAutoConfiguration {

    @Value("${spring.redisson.address}")
    private String addressUrl;

    /**
     * @return org.redisson.api.RedissonClient
     * @Author decade
     * @Description //TODO 单机模式配置
     * @Date 2020/3/19 22:54
     * @Param []
     **/
    @Bean
    public RedissonClient getRedisson() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress(addressUrl)
                .setReconnectionTimeout(10000)
                .setRetryInterval(5000)
                .setTimeout(10000)
                .setConnectTimeout(10000);
        return Redisson.create(config);
    }
}
